package com.xiu.travel.handler;

import com.xiu.travel.util.WebUtils;
import com.xiu.travel.util.api.CommonResult;
import com.xiu.travel.util.api.ResultCode;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

@Component
public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint
{
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException)
    {
        Object excepiton = request.getAttribute("excepiton");
        WebUtils.renderString(CommonResult.failed(excepiton != null ?(ResultCode)excepiton:ResultCode.FIND_NOT_RESULT));
    }
}